package org.javaqq.face.main.base;

import java.awt.Component;
import java.awt.Graphics;

import javax.swing.JScrollPane;

import org.javaqq.face.main.lookandfeel.JavaQQScrollBarUI;
import org.javaqq.face.util.JavaQQColor;


public class DefaultScrollPane extends JScrollPane {
	/**
     * Creates a <code>JScrollPane</code> that displays the view
     * component in a viewport
     * whose view position can be controlled with a pair of scrollbars.
     * The scrollbar policies specify when the scrollbars are displayed, 
     * For example, if <code>vsbPolicy</code> is
     * <code>VERTICAL_SCROLLBAR_AS_NEEDED</code>
     * then the vertical scrollbar only appears if the view doesn't fit
     * vertically. The available policy settings are listed at 
     * {@link #setVerticalScrollBarPolicy} and
     * {@link #setHorizontalScrollBarPolicy}.
     * 
     * @see #setViewportView
     * 
     * @param view the component to display in the scrollpanes viewport
     * @param vsbPolicy an integer that specifies the vertical
     *		scrollbar policy
     * @param hsbPolicy an integer that specifies the horizontal
     *		scrollbar policy
     */
    public DefaultScrollPane(Component view, int vsbPolicy, int hsbPolicy) 
    {
    	super(view,vsbPolicy,hsbPolicy);
    	this.getHorizontalScrollBar().setUI(new JavaQQScrollBarUI());
		this.getVerticalScrollBar().setUI(new JavaQQScrollBarUI());
    }


    /**
     * Creates a <code>JScrollPane</code> that displays the
     * contents of the specified
     * component, where both horizontal and vertical scrollbars appear
     * whenever the component's contents are larger than the view.
     * 
     * @see #setViewportView
     * @param view the component to display in the scrollpane's viewport
     */
    public DefaultScrollPane(Component view) {
    	this(view, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED);
    }


    /**
     * Creates an empty (no viewport view) <code>JScrollPane</code>
     * with specified 
     * scrollbar policies. The available policy settings are listed at 
     * {@link #setVerticalScrollBarPolicy} and
     * {@link #setHorizontalScrollBarPolicy}.
     * 
     * @see #setViewportView
     * 
     * @param vsbPolicy an integer that specifies the vertical
     *		scrollbar policy
     * @param hsbPolicy an integer that specifies the horizontal
     *		scrollbar policy
     */
    public DefaultScrollPane(int vsbPolicy, int hsbPolicy) {
    	this(null, vsbPolicy, hsbPolicy);
    }


    /**
     * Creates an empty (no viewport view) <code>JScrollPane</code>
     * where both horizontal and vertical scrollbars appear when needed.
     */
    public DefaultScrollPane() {
    	this(null, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED);
    }


	@Override
	protected void paintComponent(Graphics g) {
		g.setColor(JavaQQColor.getWrite());
		g.fillRect(0, 0, this.getWidth(), this.getHeight());
		//super.paintComponent(g);
	}
}
